import { IPSAppDEField } from './ipsapp-defield';
import { IPSAppDEMethodDTO } from './ipsapp-demethod-dto';
import { IPSAppDEMethodDTOField } from './ipsapp-demethod-dtofield';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodDTOFieldImpl extends PSModelObjectImpl implements IPSAppDEMethodDTOField {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get jsonFormat(): string {
    return this.M.jsonFormat;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psappdefield: IPSAppDEField | null = null;

  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdefield = ipsappdataentity.findPSAppDEField(value);
    }
    return this.psappdefield;
  }

  get psAppDEField(): IPSAppDEField | null {
    return this.getPSAppDEField();
  }

  getPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getPSAppDEField();
    if (value == null) {
      throw new Error('未指定应用实体属性');
    }
    return value;
  }

  protected refpsappdemethoddto: IPSAppDEMethodDTO | null = null;

  getRefPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    if (this.refpsappdemethoddto != null) return this.refpsappdemethoddto;
    const value = this.M.getRefPSAppDEMethodDTO;
    if (value == null) {
      return null;
    }
    this.refpsappdemethoddto = this.getRefPSAppDataEntityMust().findPSAppDEMethodDTO(value);
    return this.refpsappdemethoddto;
  }

  get refPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    return this.getRefPSAppDEMethodDTO();
  }

  getRefPSAppDEMethodDTOMust(): IPSAppDEMethodDTO {
    const value = this.getRefPSAppDEMethodDTO();
    if (value == null) {
      throw new Error('未指定引用应用实体方法DTO对象');
    }
    return value;
  }

  protected refpsappdataentity: IPSAppDataEntity | null = null;

  getRefPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.refpsappdataentity != null) return this.refpsappdataentity;
    const value = this.M.getRefPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.refpsappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getRefPSAppDataEntity') as IPSAppDataEntity;
    return this.refpsappdataentity;
  }

  get refPSAppDataEntity(): IPSAppDataEntity | null {
    return this.getRefPSAppDataEntity();
  }

  getRefPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getRefPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定引用应用实体对象');
    }
    return value;
  }

  get sourceType(): 'DEFIELD' | 'DEFGROUPDETAIL' | 'DER' | 'DYNAMODELATTR' | 'DEACTIONPARAM' | 'DEFSEARCHMODE' | 'DEDATASETPARAM' {
    return this.M.sourceType;
  }

  get stdDataType(): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 {
    return this.M.stdDataType != null ? this.M.stdDataType : 0;
  }

  get type(): 'SIMPLE' | 'SIMPLES' | 'DTO' | 'DTOS' {
    return this.M.type;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty != null ? this.M.allowEmpty : true;
  }

  get listMap(): boolean {
    return this.M.listMap != null ? this.M.listMap : false;
  }

  get cls(): string {
    return 'PSAppDEMethodDTOFieldImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'app.dataentity.IPSAppDEMethodDTOField') return true;
    return super.instanceof(cls);
  }
}
